<?php
/**
 * Wraps response according to content type. Must be extended by classes implementing type-aware response (html, json).
 */
abstract class Wrapper {
	/**
	 * Constructor performing wrapper's task
	 */
	public function __construct() {
		$this->setHeaders();
		$this->setResponse();
	}
	
	/**
	 * Sets extra headers (using Servlet::$response->getHeader(...)) or content type (using Servlet::$response->getContentType()) into response object
	 */
	abstract protected function setHeaders();
	
	/**
	 * Outputs response and captures output in buffer, then sets contents to output stream (using Servlet::$response->setOutputStream(...)) into response object.
	 */
	abstract protected function setResponse();
}